﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;

public partial class HomePage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            SqlConnection conn;
            string connectionString = ConfigurationManager.ConnectionStrings["ExamScheduleDBConString"].ConnectionString;
            conn = new SqlConnection(connectionString);
            SqlCommand comm = new SqlCommand("sp_CountOfExamsByProfName", conn);
            SqlCommand commInvigCount = new SqlCommand("sp_CountOfAdditionalInvigilations", conn);
            comm.CommandType = System.Data.CommandType.StoredProcedure;
            comm.Parameters.Add("@profName",
               System.Data.SqlDbType.Text);
            comm.Parameters["@profName"].Value = Session["UserName"];

            commInvigCount.CommandType = System.Data.CommandType.StoredProcedure;
            commInvigCount.Parameters.Add("@profName",
               System.Data.SqlDbType.Text);
            commInvigCount.Parameters["@profName"].Value = Session["UserName"];
            SqlDataReader reader;
            SqlDataReader readerAddInvig;

            try
            {
                conn.Open();
                reader = comm.ExecuteReader();
                while(reader.Read())
                lblCountOfMyExams.Text = reader.GetSqlValue(0)+"";
                reader.Close();

                readerAddInvig = commInvigCount.ExecuteReader();
                while (readerAddInvig.Read())
                lblCountOfMyVolunteers.Text = readerAddInvig.GetSqlValue(0) + "";
            }
            finally
            {
                conn.Close();
            }
        }
    }
}